package o;

import android.util.Log;
import com.huawei.android.fsm.HwFoldScreenManagerEx;
import com.huawei.android.fsm.HwFoldScreenManagerEx.FoldDisplayModeListener;
import com.huawei.android.util.NoExtAPIException;
import com.huawei.appmarket.component.buoywindow.util.HwFoldDisplayModeListener;

public class dfe {
    private static dfe ॱ;
    private int ˊ = -1;
    private FoldDisplayModeListener ˏ;

    public interface d {
        void ˊ();
    }

    public static synchronized dfe ˊ() {
        dfe o_dfe;
        synchronized (dfe.class) {
            if (ॱ == null) {
                ॱ = new dfe();
            }
            o_dfe = ॱ;
        }
        return o_dfe;
    }

    public boolean ॱ() {
        int i = 1;
        if (this.ˊ == -1) {
            boolean isFoldable;
            try {
                isFoldable = HwFoldScreenManagerEx.isFoldable();
            } catch (SecurityException e) {
                Log.e("HwFoldScreenSupport", "isFoldScreen SecurityException");
                isFoldable = false;
            } catch (NoExtAPIException e2) {
                Log.w("HwFoldScreenSupport", "isFoldScreen NoExtAPIException");
                isFoldable = false;
            } catch (Exception e3) {
                Log.w("HwFoldScreenSupport", "isFoldScreen Exception");
                isFoldable = false;
            } catch (Throwable th) {
                Log.w("HwFoldScreenSupport", "isFoldScreen Throwable");
                isFoldable = false;
            }
            if (!isFoldable) {
                i = 0;
            }
            this.ˊ = i;
            return isFoldable;
        } else if (this.ˊ == 1) {
            return true;
        } else {
            return false;
        }
    }

    public void ˊ(d dVar) {
        if (ॱ()) {
            try {
                this.ˏ = new HwFoldDisplayModeListener(dVar);
                HwFoldScreenManagerEx.registerFoldDisplayMode(this.ˏ);
            } catch (SecurityException e) {
                Log.w("HwFoldScreenSupport", "registerFoldDisplayMode SecurityException");
            } catch (NoExtAPIException e2) {
                Log.w("HwFoldScreenSupport", "registerFoldDisplayMode NoExtAPIException");
            } catch (Exception e3) {
                Log.w("HwFoldScreenSupport", "registerFoldDisplayMode Exception");
            } catch (Throwable th) {
                Log.w("HwFoldScreenSupport", "registerFoldDisplayMode Throwable");
            }
        }
    }

    public void ˎ() {
        if (ॱ() && this.ˏ != null) {
            try {
                HwFoldScreenManagerEx.unregisterFoldDisplayMode(this.ˏ);
            } catch (SecurityException e) {
                Log.w("HwFoldScreenSupport", "unregisterFoldDisplayMode SecurityException");
            } catch (NoExtAPIException e2) {
                Log.w("HwFoldScreenSupport", "unregisterFoldDisplayMode NoExtAPIException");
            } catch (Exception e3) {
                Log.w("HwFoldScreenSupport", "unregisterFoldDisplayMode Exception");
            } catch (Throwable th) {
                Log.w("HwFoldScreenSupport", "unregisterFoldDisplayMode Throwable");
            }
        }
    }
}
